package gem.model.core;

public class ScienceDomain implements DBEntity {
    //-----------------------------------------------------------------------------------//

    public Department getDepartment() {
        return m_Department;
    }
    //-----------------------------------------------------------------------------------//
    private java.util.Collection<Course> m_Courses;
    //-----------------------------------------------------------------------------------//

    public java.util.Collection<Course> getCourses() {
        return m_Courses;
    }

    public ScienceDomain setCourses(java.util.Collection<Course> c) {
        m_Courses = c;

        return this;
    }
    //-----------------------------------------------------------------------------------//
    private String m_ScienceDomainTitle;
    private int m_ScienceDomainId;
    //----------------------------------------------------------------------------------//
    private Department m_Department;
    //----------------------------------------------------------------------------------//

    public String getTitle() {
        return m_ScienceDomainTitle;
    }

    public ScienceDomain setTitle(String title) {
        m_ScienceDomainTitle = title;
        return this;
    }
    //-----------------------------------------------------------------------------------//

    public int getId() {
        return m_ScienceDomainId;
    }

    public ScienceDomain setId(int id) {
        m_ScienceDomainId = id;
        return this;
    }
    //-----------------------------------------------------------------------------------//
    // This function is accessed only from department

    protected ScienceDomain setDepartment(Department d) {
        // First, we have to remove ScienceDomain from current parent
        if (m_Department != null)
        {
            m_Department.removeScienceDomain(this);
        }

        m_Department = d;

        return this;
    }
    //-----------------------------------------------------------------------------------//

    public ScienceDomain addCourse(Course c)
    {
        if (!m_Courses.contains(c))
        {
            m_Courses.add(c);
            c.setScienceDomain(this);
        }

        return this;
    }
    //-----------------------------------------------------------------------------------//

    public ScienceDomain removeCourse(Course c) {
        m_Courses.remove(c);

        return this;
    }
    //-----------------------------------------------------------------------------------//

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof Department == false) {
            return false;
        }
        if (this == obj) {
            return true;
        }
        ScienceDomain temp = (ScienceDomain) obj;
        return ((temp.getId() == this.getId())
                && (temp.getTitle().equals(this.getTitle())));
    }
    //-----------------------------------------------------------------------------------//

    @Override
    public int hashCode() {
        return getTitle().hashCode();
    }
    //-----------------------------------------------------------------------------------//

    @Override
    public String toString() {
        return m_ScienceDomainTitle;
    }

    public EntityType getType() {
        return EntityType.SCIENCEDOMAIN;
    }
    //-----------------------------------------------------------------------------------//
    //-----------------------------------------------------------------------------------//
    public String getCaption()
    {
        return getTitle();
    }
    //-----------------------------------------------------------------------------------//

    //-----------------------------------------------------------------------------------//
}
